/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GUI;
import Model.SendEmail;
import javax.microedition.lcdui.*;
/**
 *
 * @author Pisarchik_S
 */
public class MainMenuEditor implements ItemCommandListener
{
    Dispatcher m_Dispatcher;

    public MainMenuEditor(Dispatcher dispatcher)
    {
        m_Dispatcher = dispatcher;
    }

    Command m_EditMonth = new Command("Рэдагаваць", Command.ITEM, 0);
    Command m_EditCategories = new Command("Рэдагаваць", Command.ITEM, 0);
    Command m_SaveToFile = new Command("Захаваць", Command.ITEM, 0);
    Command m_SendEmail = new Command("Адаслаць", Command.ITEM, 0);
    Command m_EmailSettings = new Command("Рэдагаваць", Command.ITEM, 0);
    Command m_ShowStatistics = new Command("Паказаць", Command.ITEM, 0);
    Command m_ClearAll = new Command("Спустошыць", Command.ITEM, 0);
    Command m_About = new Command("Аб праграме", Command.ITEM, 0);

    public void Init()
    {
        Form form = new Form("Галоўнае Мэню");
        StringItem si;
        si = new StringItem("","Статыстыка");
        si.setDefaultCommand(m_ShowStatistics);
        si.setItemCommandListener(this);
        si.setPreferredSize(400, 10);
        form.append(si);
        si = new StringItem("","Рэдагаваць выдаткі");
        si.setPreferredSize(400, 10);
        si.setDefaultCommand(m_EditMonth);
        si.setItemCommandListener(this);
        form.append(si);
        si = new StringItem("","Захаваць як файл");
        si.setDefaultCommand(m_SaveToFile);
        si.setItemCommandListener(this);
        si.setItemCommandListener(this);
        si.setPreferredSize(400, 10);
        form.append(si);
        si = new StringItem("","Адаслаць на EMail");
        si.setDefaultCommand(m_SendEmail);
        si.setItemCommandListener(this);
        si.setItemCommandListener(this);
        si.setPreferredSize(400, 10);
        form.append(si);
        si = new StringItem("","Рэдагаваць катэгорыі");
        si.setDefaultCommand(m_EditCategories);
        si.setItemCommandListener(this);
        si.setPreferredSize(400, 10);
        form.append(si);
        si = new StringItem("","Наладкі EMail");
        si.setDefaultCommand(m_EmailSettings);
        si.setItemCommandListener(this);
        si.setItemCommandListener(this);
        si.setPreferredSize(400, 10);
        form.append(si);
        si = new StringItem("","Выдаліць усе запісы");
        si.setDefaultCommand(m_ClearAll);
        si.setItemCommandListener(this);
        si.setPreferredSize(400, 10);
        form.append(si);
        si = new StringItem("","Аб праграме");
        si.setDefaultCommand(m_About);
        si.setItemCommandListener(this);
        si.setPreferredSize(400, 10);
        form.append(si);

        m_Dispatcher.GetDisplay().setCurrent(form);
    }

    public void commandAction(Command c, Item item)
    {
        if (c == m_EditMonth)
        {
            m_Dispatcher.GetShowMonth().Init();
            return;
        }
        if (c == m_EditCategories)
        {
            m_Dispatcher.GetShowCategories().Init();
        }
        if (c == m_ShowStatistics)
        {
            m_Dispatcher.GetAskForThanks().Init();
        }
        if (c == m_ClearAll)
        {
            m_Dispatcher.ClearAll();
        }
        if (c == m_SendEmail)
        {
            m_Dispatcher.SendEmail();
        }
        if (c == m_SaveToFile)
        {
            m_Dispatcher.SaveAsFile();
        }
        if (c == m_EmailSettings)
        {
            m_Dispatcher.GetEditEmailSettings().Init();
        }
        if (c == m_About)
        {
            m_Dispatcher.GetAbout().Init();
        }
    }
}
